package com.vitabuybuy.tv.ui.mine.adapter

import android.graphics.Color
import android.view.View
import androidx.recyclerview.widget.RecyclerView
import com.library.common.base.BindRecycAdapter
import com.vitabuybuy.tv.R
import com.vitabuybuy.tv.databinding.ItemPointRewards2Binding
import com.vitabuybuy.tv.databinding.ItemPointRewardsBinding
import com.vitabuybuy.tv.dto.ActivityNode

class PointRewardsAdapter2(val quantity: Int) :
    BindRecycAdapter<ItemPointRewards2Binding, ActivityNode>() {
    override fun onBindViewHolder(
        mBinding: ItemPointRewards2Binding,
        itemData: ActivityNode,
        holder: RecyclerView.ViewHolder,
        position: Int
    ) {
        mBinding.pointQuantity.text =
            String.format(mContext.getString(R.string.sign_days), itemData.quantity)
        if (quantity >= itemData.quantity) {
            mBinding.pointView2.setImageResource(R.drawable.icon_common_choose_s)
            mBinding.endView.setBackgroundColor(Color.parseColor("#E23225"))
        } else {
            mBinding.pointView2.setImageResource(R.drawable.icon_common_choose_n)
            mBinding.endView.setBackgroundColor(Color.parseColor("#DDE0E6"))
        }
        when (position) {
            0 -> {
                mBinding.endView.visibility = View.VISIBLE
            }
            mData.size - 1 -> {
                mBinding.endView.visibility = View.GONE
            }
            else -> {
                mBinding.endView.visibility = View.VISIBLE
            }
        }
    }

    override fun normalViewId(viewType: Int): Int {
        return R.layout.item_point_rewards_2
    }
}
